{__NOLAYOUT__}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="__PUBLIC__/CSS/shopping.css">
    <link rel="stylesheet" href="__PUBLIC__/CSS/foot.css">
    <script src="__PUBLIC__/js/jquery-1.11.3.js"></script>

</head>
<body style="background-color: #F5F5F5">
<div class="body">
    <div class="header">
        <div class="shortcut">
            <div class="s-min">
                <ul>
                    <?php
       if(!$_SESSION['user_id']){
?>
                    <li>
                        <span class="gou"></span>
                        <a href="__URL__/shopping">购物车（0）</a>
                    </li>
                    <li style="border-right: 1px solid #DDDDDD;height: 15px; border-left: 1px solid #DDDDDD ">
                        <a href="__URL__/order">我的订单</a>
                    </li>

                    <li>
                        <a href="__URL__/register.html">注册</a>
                    </li>

                    <li>
                        <a href="__URL__/login.html">请登录</a>
                    </li>
                    <?php
        }else{
        ?>
                    <li>
                        <span class="gou"></span>
                        <a href="__URL__/shopping">购物车（{$num}）</a>
                    </li>
                    <li style="border-right: 1px solid #DDDDDD;height: 15px; border-left: 1px solid #DDDDDD ">
                        <a href="__URL__/order"> 我的订单 </a>
                    </li>
                    <li>
                        <a href="__URL__/loginOut">退出</a>
                    </li>
                    <?php
            if($UserData['gm']<2 && $UserData['gm']>=0 ){
                    ?>
                    <li>
                        <a href="__MODULE__/backstage/backstage">去后台</a>
                    </li>
                    <?php
            }
?>
                    <li>
                        <a href="__URL__/person">{$UserData.username}</a>
                    </li>
                    <?php
            }
            ?>
                </ul>
            </div>
        </div>
        <div style="clear: right"></div>
        <div class="layout">
            <div class="left">
                <a href="__URL__/index">
                    <img src="__PUBLIC__/image/biao.png" alt="">
                </a>
                <span>我的购物车</span>
                <div class="right">
                    <div>我的购物车</div>
                </div>
            </div>
        </div>
    </div>
</div>
<form action="__CONTROLLER__/Settlement" method="post" id="myform">
<div class="sc-list">
    <div class="sc-pro">
        <label>
            <input type="checkbox" class="all">全选
        </label>
        <span class="b-a">商品</span>
        <span>单价</span>
        <span> 数量</span>
        <span>小计</span>
        <span>操作</span>

    </div>
</div>
<volist name="data" id="list">

    <div class="b-list js_form">
        <div class="b-shopping">
            <ul class="chk">
                <li><input type="checkbox" class="box" name="chkGoogs[{$list.product_id}]" value="{$list.product_id}"></li>
                <li><img src="__UPLOAD__/{$list.image}" width="100px" height="100px" alt=""></li>
                <li class="b-commodity">
                    <p>{$list.product_name} {$list.product_info}</p>
                </li>
                <li class="b-price">
                    ￥<span id="jiaqian" class="js_price jiaqian">{$list.original_price}.00</span>
                    <s>￥{$list.current_price}.00</s>
                </li>
                <li style="position: relative">
                    <input class="text js_num num" type="text" name="goodsNum[{$list.product_id}]" value="{$list.product_carnum}" id="num">
                    <div style=" font-size: 20px;text-align: center;cursor: pointer;display: inline;position: absolute;top: -45px;left: 98px"
                         id="add"  class="add"><b>+</b></div>
                    <div style="font-size: 20px;text-align: center;line-height: 15px;cursor:pointer;display: inline;;position: absolute;top: 17px;left: 102px"
                         id="less" class="less"><b>-</b></div>
                </li>
                <li class="b-price">
                    ￥<span id="b-ji2" class="b-ji2">￥{$list.original_price}.00</span>
                    <s>￥{$list.current_price}.00</s>
                </li>
                <li class="shan">
                    <a href="__URL__/shopping_del?id={$list.product_id}">删除</a>
                </li>
            </ul>
        </div>
    </div>
</volist>
    <div class="sc-list2">
        <div class="sc-pro2">
            <label>
                <input type="checkbox" id="unSelect" >全不选
            </label>
            <span>删除</span>
            <div class="b-right">
                <a href="__URL__/Settlement">立即结算</a>
            </div>
            <div class="b-ka">
                <div class="b-zong">总计：</div>
                ￥<div class="b-ji" id="b-ji">{$list.original_price}</div>
            </div>

        </div>
    </div>
</div>
</form>
</div>
<script>


//    var add = document.querySelector(".add");
//    var num = document.querySelector('.num');
//    var less= document.querySelector('.less');
//
//
//    add.onclick = function (){
//        var newnum = num.value;
//        console.log(newnum);
//        i = parseInt(newnum) + 1 ;
//        num.value = i;
//        var jia=jiaqian.innerHTML;
//        console.log(jia);
//        var  nnn=num.value;
//        console.log(nnn);
//        bji.innerHTML=jia*nnn;
//
//
//    }
//
//    less.onclick = function (){
//        var newnum = num.value;
//        console.log(newnum);
//        i = parseInt(newnum) - 1 ;
//        num.value = i;
//        var jia=jiaqian.innerHTML;
//        console.log(jia);
//        var  nnn=num.value;
//        console.log(nnn);
//        bji.innerHTML=jia*nnn;
//        if(newnum<2){
//            num.value = 1;
//        }
//
//    }
//
//    var bji= document.querySelector('.b-ji');
//    var jiaqian =document.querySelector('.jiaqian');
//
//    function move() {
//        var jia=jiaqian.innerHTML;
//        console.log(jia);
//        var  nnn=num.value;
//        console.log(nnn);
//      bji.innerHTML=jia*nnn;
//     // console.log(bji);
//
//    }
//move();

   $(".add").click(function () {

       var num = parseInt($(this).parent().parent().find(".js_num ").val());
      $(this).parent().parent().find(".js_num ").val(num+1);

       calcPrice()

   });
   $(".less").click(function () {
       var num = parseInt($(this).parent().parent().find(".js_num ").val());
       $(this).parent().parent().find(".js_num ").val(num-1);
       calcPrice()
   });



    $("#all").click(function(){
        if(this.checked){
            $(".chk :checkbox").prop("checked", true);
            $("#unSelect").prop("checked",false);
        }else{
            $(".chk :checkbox").prop("checked", false);
        }
    });

    $("#unSelect").click(function () {
        $(".chk :checkbox,#all").prop("checked", false);
    });

  //  document.querySelector("")     可以在循环的时候和创建的id运用javascript不失效
    function calcPrice(){
        var total = 0;
        $(".js_form").each(function (i) {
            $nowRow = $(this);
            var price = $nowRow.find(".js_price").html();
            var num = $nowRow.find(".js_num").val();
            total += price*num;

        });
        console.log(total);
        $("#b-ji").html(total);

    }
    calcPrice();

    $(".all_price").click(function () {
        $("#myform").submit();
    })

</script>


</body>
</html>
